home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / lightwave / arexx_macros / lwscenemacros / lw.txt < prev    next >
Text File  |  1994-09-05  |  16KB  |  374 lines

  1.                    LIGHTWAVE 3D OBJECT FILE FORMAT
  2.  
  3.                           by Allen Hastings
  4.                           revised  11/10/93
  5.  
  6.  
  7. Introduction
  8.  
  9.   LightWave 3D objects are stored as IFF files with a FORM type of
  10.   LWOB.  Currently, a FORM LWOB must contain a PNTS chunk, a SRFS
  11.   chunk, and a POLS chunk (in that order).  These may be followed by
  12.   zero or more SURF chunks.  LightWave 2.0 also has the ability to
  13.   save and load surface descriptions as FORM LWOB files that contain
  14.   only a SURF chunk.
  15.  
  16.   This document explains the contents of each chunk and includes an
  17.   annotated listing of a FORM LWOB as an example.
  18.  
  19.  
  20. PNTS Chunk
  21.  
  22.   This chunk contains a list of the X, Y, and Z coordinates of all
  23.   the points in an object.  Each coordinate is stored as a four byte
  24.   floating point number in IEEE format.  Therefore, the number of
  25.   points in an object can be determined by dividing the size in bytes
  26.   of the PNTS chunk by 12.
  27.  
  28.   By convention, the +X direction is to the right or east, the +Y
  29.   direction is upward, and the +Z direction is forward or north.
  30.   For models of real-world objects, the unit size is usually
  31.   considered to be one meter.  The coordinates are specified relative
  32.   to an object's pivot point.  See the LightWave Modeler manual for
  33.   more information about LightWave 3D's geometric conventions.
  34.  
  35.  
  36. SRFS Chunk
  37.  
  38.   This chunk contains a list of the names of all the surfaces in an
  39.   object (note that in LightWave 3D terminology, the word "surface"
  40.   is defined as a set of attributes that describe the color and
  41.   shading characteristics of a group of polygons).  Each surface name
  42.   appears as a null-terminated character string.  If the length of
  43.   the string (including the null) is odd, an extra null byte is
  44.   added.  Surface names should be read from the file until as many
  45.   bytes as the chunk size specifies have been read.
  46.  
  47.  
  48. POLS Chunk
  49.  
  50.   This chunk contains a list of all the polygons in an object.  Each
  51.   entry consists of a short integer specifying the number of vertices
  52.   in a polygon followed by that many short integers specifying the
  53.   vertices themselves (as indices into the points list) followed by a
  54.   short integer specifying which surface is used by the polygon (as
  55.   an index into the surfaces list).  The number of vertices in a
  56.   polygon currently may vary from one to 200.  The vertex list for
  57.   each polygon should begin at a convex vertex and proceed clockwise
  58.   as seen from the visible side of the polygon (LightWave 3D polygons
  59.   are single-sided, except for those whose surfaces have the double-
  60.   sided flag set).  The points list in the PNTS chunk is numbered
  61.   starting with zero and the surfaces list in the SRFS chunk is
  62.   numbered starting with one (so that surface numbers can be made
  63.   negative to signal the presence of detail polygons as explained
  64.   below).  Polygons should be read from the file until as many bytes
  65.   as the chunk size specifies have been read.
  66.  
  67.   A negative surface number for a polygon indicates that the polygon
  68.   has detail polygons (which are drawn on top of the main polygon and
  69.   may be coplanar with it).  In this case, the next number in the
  70.   file is a short integer specifying how many detail polygons belong
  71.   to the current polygon.  This is followed by a list of those detail
  72.   polygons, where each entry is of the same format as described above
  73.   for regular polygons (except that the detail polygons cannot have
  74.   details of their own).  The list of regular polygons then resumes.
  75.   To determine which surface is used by a polygon with a negative
  76.   surface number, the absolute value of that number should be used.
  77.  
  78.  
  79. SURF Chunks
  80.  
  81.   Each SURF chunk describes the surface attributes of a particular
  82.   surface.  These chunks begin with the name of the surface being
  83.   described.  The name is stored as a character string with either
  84.   one or two trailing nulls (as explained in the SRFS chunk section).
  85.   Following the name is a series of sub-chunks, which are like normal
  86.   IFF chunks except that their sizes are specified by short integers
  87.   instead of longs.  It is likely that the variety of sub-chunks will
  88.   grow as new surface attributes are added to the program, but any
  89.   unknown sub-chunks may be skipped over in the usual IFF fashion.
  90.   Sub-chunks should be read from the file until as many bytes as the
  91.   chunk size specifies have been read.
  92.  
  93.   COLR Sub-Chunk
  94.  
  95.     This sub-chunk consists of three bytes that specify the red,
  96.     green, and blue color components of the current surface, followed
  97.     by a byte which is currently ignored and should be zero.  A
  98.     surface can therefore be any of 16,777,216 possible colors.
  99.  
  100.   FLAG Sub-Chunk
  101.  
  102.     This sub-chunk contains a short integer whose bits specify
  103.     various options for the current surface.  Currently only the
  104.     nine least significant bits are used.  The options that set bits
  105.     indicate are (starting with the least significant bit):
  106.     Luminous, Outline, Smoothing, Color Highlights, Color Filter,
  107.     Opaque Edge, Transparent Edge, Sharp Terminator, Double Sided,
  108.     and Additive (which is new for LW 3.0).  Note that the two edge
  109.     transparency bits should not both be set.
  110.  
  111.   LUMI, DIFF, SPEC, REFL, and TRAN Sub-Chunks
  112.  
  113.     Each of these sub-chunks contain a short integer that specifies
  114.     the current surface's luminosity, diffuse, specular, reflection,
  115.     or transparency settings (the LUMI sub-chunk is new for LW 3.0,
  116.     and replaces the Luminous bit of the FLAG sub-chunk).  A value of
  117.     256 in the file corresponds to a setting of 100% on the control
  118.     panel.  If any of these sub-chunks are absent for a surface, a
  119.     value of zero is assumed for the corresponding parameter.
  120.  
  121.   GLOS Sub-Chunk
  122.  
  123.     This sub-chunk contains a short integer that specifies the
  124.     glossiness of the current surface, and is only needed if the
  125.     specular setting in the SPEC sub-chunk is non-zero.  A value of
  126.     16 indicates low glossiness, 64 indicates medium glossiness, 256
  127.     indicates high glossiness, and 1024 indicates maximum glossiness
  128.     (the maximum setting is new for LW 3.0).  This parameter is
  129.     related to the "specular exponent" used in many lighting models.
  130.  
  131.   RIMG Sub-Chunk
  132.  
  133.     This sub-chunk contains the filename (including any path the user
  134.     may have specified) of the image to be used as a reflection map
  135.     for the current surface.  Once again, if the length of the string
  136.     (including the terminating null) is odd, another null is added.
  137.     If the last part of the string is " (sequence)", then the first
  138.     part of the string specifies the prefix of an image sequence (the
  139.     actual filename in this case is generated by appending a three
  140.     digit frame number to the prefix when loading the image file for
  141.     each frame).  If the reflection setting in the REFL sub-chunk is
  142.     non-zero but no RIMG sub-chunk is present, then the surface is
  143.     assumed to reflect the sky and ground backdrop (or to use ray
  144.     traced reflection if ray tracing is enabled).
  145.  
  146.   RSAN Sub-Chunk
  147.  
  148.     This sub-chunk contains a four byte IEEE floating point number
  149.     that specifies the heading angle of the reflection map seam
  150.     (expressed in degrees).  This is new for LW 3.0.
  151.  
  152.   RIND Sub-Chunk
  153.  
  154.     This sub-chunk contains a four byte IEEE floating point number
  155.     that specifies the current surface's refractive index, which is
  156.     defined as the ratio of the speed of light in a vacuum to the
  157.     speed of light in the material.  Since light is fastest in a
  158.     vacuum, this value should therefore be greater than or equal to
  159.     1.0.
  160.  
  161.   EDGE Sub-Chunk
  162.  
  163.     This sub-chunk contains a four byte IEEE floating point number
  164.     that specifies the edge transparency threshold of the current
  165.     surface.  This value should lie between 0.0 and 1.0.
  166.  
  167.   SMAN Sub-Chunk
  168.  
  169.     This sub-chunk contains a four byte IEEE floating point number
  170.     that specifies the maximum angle between two adjacent polygons
  171.     that can be smooth shaded (expressed in degrees).  Polygons with
  172.     a greater angle between them will appear to meet at a sharp seam.
  173.     This is new for LW 3.0.
  174.  
  175.   CTEX, DTEX, STEX, RTEX, TTEX, and BTEX Sub-Chunks
  176.  
  177.     The presence of one of these sub-chunks indicates that the
  178.     current surface has a color, diffuse, specular, reflection,
  179.     transparency, or bump texture.  The contents of the sub-chunk is
  180.     a character string (terminated by one or two nulls as usual)
  181.     specifying the texture type as shown on the control panel.  Once
  182.     one of these sub-chunks is encountered within a SURF chunk, all
  183.     subsequent texture-related sub-chunks (those described below) are
  184.     considered to pertain to the current texture, until another CTEX,
  185.     DTEX, STEX, RTEX, TTEX, or BTEX sub-chunk is read.  Currently
  186.     there may be zero or one of each of these sub-chunks (up to six
  187.     textures) in each SURF chunk.
  188.  
  189.   TIMG Sub-Chunk
  190.  
  191.     This sub-chunk specifies the filename of the image (or the prefix
  192.     of the image sequence) to be used for image texture mapping.  See
  193.     the description of the RIMG sub-chunk above for more details.
  194.  
  195.   TFLG Sub-Chunk
  196.  
  197.     This sub-chunk contains a short integer whose bits specify
  198.     various options for the current texture.  Currently only the
  199.     seven least significant bits are used.  The options that set bits
  200.     indicate are (starting with the least significant bit):  X Axis,
  201.     Y Axis, Z Axis, World Coords, Negative Image, Pixel Blending, and
  202.     Antialiasing.  Note that only one of the three axis bits should
  203.     be set.
  204.  
  205.   TSIZ, TCTR, TFAL, and TVEL Sub-Chunks
  206.  
  207.     These sub-chunks each consist of three IEEE four byte floating
  208.     point numbers that specify the X, Y, and Z components of the
  209.     current texture's size, center, falloff, or velocity.  The TCTR,
  210.     TFAL, and TVEL sub-chunks are only needed if the corresponding
  211.     parameters are non-zero.
  212.  
  213.   TCLR Sub-Chunk
  214.  
  215.     This sub-chunk contains four bytes that specify the texture color
  216.     for the current texture, which should be of the color-modifying
  217.     variety (in other words, there should be a CTEX sub-chunk
  218.     somewhere before this sub-chunk).  The bytes are interpreted as
  219.     described above in the COLR sub-chunk section.
  220.  
  221.   TVAL Sub-Chunk
  222.  
  223.     This sub-chunk contains a short integer that specifies the
  224.     texture value of a diffuse, specular, reflection, or transparency
  225.     texture, so it should appear somewhere after a DTEX, STEX, RTEX,
  226.     or TTEX sub-chunk.  A value of 256 in the file corresponds to a
  227.     a setting of 100% on the control panel.
  228.  
  229.   TAMP Sub-Chunk
  230.  
  231.     This sub-chunk contains a four byte IEEE floating point number
  232.     that specifies the amplitude of the current bump texture, so it
  233.     should appear somewhere after a BTEX sub-chunk.  A value of 1.0
  234.     is equivalent to a setting of 100% on the control panel.
  235.  
  236.   TFRQ Sub-Chunk
  237.  
  238.     This sub-chunk contains a short integer that specifies the number
  239.     of noise frequencies or wave sources used by the current texture.
  240.  
  241.   TSP0, TSP1, and TSP2 Sub-Chunks
  242.  
  243.     These sub-chunks each contain a four byte IEEE floating point
  244.     number that specifies one of the special texture type-specific
  245.     parameters (such as Contrast, Turbulence, Wavelength, etc).
  246.     Which sub-chunk is used to record a particular parameter depends
  247.     on the order in which that parameter's button appears on the
  248.     control panel.  In the future there may be more than three of
  249.     these per texture.
  250.  
  251.  
  252. Object File Example
  253.  
  254.   A simple object (with somewhat complex surfaces) is listed below to
  255.   illustrate some of the features of a FORM LWOB.  The object is an
  256.   image-mapped bumpy square polygon in the XY plane with a shiny
  257.   transparent yellow triangle as a detail polygon.  Each line of the
  258.   listing shows 16 bytes in hexadecimal form followed by their ASCII
  259.   equivalents.  The notes under each line should be read from left to
  260.   right rather than top to bottom.
  261.  
  262.   464F524D 0000019C 4C574F42 504E5453    FORM....LWOBPNTS
  263.   00000054 3F800000 3F800000 00000000    ...T?...?.......
  264.            ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
  265.            The X, Y, and Z coordinates of point number zero are 1.0,
  266.            1.0, and 0.0 (in IEEE format).
  267.       ^^^^
  268.       There are 84 bytes in the PNTS chunk, so there are seven points
  269.       in the object.
  270.  
  271.   BF800000 3F800000 00000000 3F800000    ....?.......?...
  272.   BF800000 00000000 BF800000 BF800000    ................
  273.   00000000 3F000000 BF000000 00000000    ....?...........
  274.   00000000 3F000000 00000000 BF000000    ....?...........
  275.   BF000000 00000000 53524653 00000012    ........SRFS....
  276.   53717561 72650000 54726961 6E676C65    Square..Triangle
  277.                ^^^^
  278.                The surface name "Square" is terminated with two nulls
  279.                to even out the number of bytes.
  280.  
  281.   0000504F 4C530000 00180004 00010000    ..POLS..........
  282.                         ^^^^
  283.                         The first polygon has four vertices (which
  284.                         are points 1, 0, 2, and 3).
  285.  
  286.   00020003 FFFF0001 00030005 00040006    ................
  287.                     ^^^^
  288.                     The detail polygon has three vertices (which are
  289.                     points 5, 4, and 6).
  290.                ^^^^
  291.                One detail polygon follows.
  292.            ^^^^
  293.            The first polygon's surface code is -1, so it uses surface
  294.            number one ("Square") and has detail polygons.
  295.  
  296.   00025355 52460000 00AE5371 75617265    ..SURF....Square
  297.       ^^^^ ^^^^
  298.       This begins the description of the surface called "Square".
  299.   ^^^^
  300.   The detail polygon uses surface number two ("Triangle").
  301.  
  302.   0000434F 4C520004 C8C8C800 464C4147    ..COLR......FLAG
  303.   00020000 44494646 00020100 43544558    ....DIFF....CTEX
  304.                              ^^^^^^^^
  305.                              The next set of texture sub-chunks
  306.                              pertain to the surface's color texture.
  307.                         ^^^^
  308.                         The "Square" surface's diffuse setting is
  309.                         100% (256 out of 256).
  310.  
  311.   0012506C 616E6172 20496D61 6765204D    ..Planar Image M
  312.       ^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
  313.       The color texture is planar mapping of the image in the IFF
  314.       file "RAM:Laura".
  315.  
  316.   61700000 54494D47 000A5241 4D3A4C61    ap..TIMG..RAM:La
  317.   75726100 54464C47 00020004 5453495A    ura.TFLG....TSIZ
  318.                         ^^^^
  319.                         The flag bits indicate that the image is to
  320.                         be projected along the Z axis.
  321.  
  322.   000C4000 00003FC0 00003F80 00005443    ..@...?...?...TC
  323.       ^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^
  324.       The X, Y, and Z texture sizes are 2.0, 1.5, and 1.0.
  325.  
  326.   4C520004 00000000 42544558 000E4672    LR......BTEX..Fr
  327.                     ^^^^^^^^
  328.                     The next set of texture sub-chunks pertain to the
  329.                     "Square" surface's bump texture.
  330.  
  331.   61637461 6C204275 6D707300 54464C47    actal Bumps.TFLG
  332.   0002000A 5453495A 000C3DCC CCCD3DCC    ....TSIZ..=...=.
  333.       ^^^^
  334.       The flag bits indicate that "Worlds Coords" is turned on.
  335.  
  336.   CCCD3DCC CCCD5441 4D500004 3FC00000    ..=...TAMP..?...
  337.                              ^^^^^^^^
  338.                              The amplitude of the bumps is 150% (1.5
  339.                              in IEEE format).
  340.  
  341.   54465251 00020001 53555246 00000044    TFRQ....SURF...D
  342.                     ^^^^^^^^
  343.                     This begins the description of the surface called
  344.                     "Triangle".
  345.                ^^^^
  346.                The bump texture uses one frequency of noise.
  347.  
  348.   54726961 6E676C65 0000434F 4C520004    Triangle..COLR..
  349.   F0B40000 464C4147 00020000 44494646    ....FLAG....DIFF
  350.   ^^^^^^^^
  351.   The "Triangle" surface's color is yellow (240 red, 180 green, and 0
  352.   blue).
  353.  
  354.   0002009A 53504543 000200CD 474C4F53    ....SPEC....GLOS
  355.                         ^^^^
  356.                         The surface's specular setting is 80 % (205
  357.                         out of 256).
  358.  
  359.   00020100 5245464C 00020033 5452414E    ....REFL...3TRAN
  360.                         ^^^^
  361.                         The surface's reflection map setting is 20%
  362.                         (51 out of 256), but there is no RIMG sub-
  363.                         chunk, so the surface reflects the backdrop.
  364.       ^^^^
  365.       The surface has a high glossiness (256).
  366.  
  367.   00020066                               ...f
  368.       ^^^^
  369.       The surface is 40% transparent (102 out of 256).
  370.  
  371.   The "Triangle" surface has no textures, and there are no more
  372.   surfaces to be defined, so the object file ends here.
  373.  
  374.